package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ExamineFile;
import com.dragon.repository.entity.ExamineUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ExamineUserVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键id")
    private Integer id;

    @ApiModelProperty(value = "审核主表id")
    private Integer examineId;

    @ApiModelProperty(value = "当前审核人id")
    private Integer auditUserId;

    @ApiModelProperty(value = "审核状态：0：待审核，1：同意，2：拒绝")
    private Integer status;

    @ApiModelProperty(value = "上一审核状态：0，未审核，1、同意，2，不同意")
    private Integer preStatus;

//    @ApiModelProperty(value = "审核类型：0，审核，1、反审核")
//    private Integer examineType;

    @ApiModelProperty(value = "意见")
    private String opinion;

    @ApiModelProperty(value = "添加时间")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @ApiModelProperty(value = "审核时间")
    private Date auditTime;

    @ApiModelProperty(value = "流程类型")
    private Integer type;

    @ApiModelProperty(value = "主表id")
    private Integer mainId;

    @ApiModelProperty(value = "附件信息")
    private List<ExamineFile> examineFiles;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ExamineUser convert(ExamineUserVO vo) {
        ExamineUser entity = new ExamineUser();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ExamineUser> convertList(List<ExamineUserVO> list) {
        List<ExamineUser> resultList = new ArrayList<>();
        for (ExamineUserVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
